/**
 * 
 */
package com.wubo.bm.user.acl;

import com.wubo.bm.user.entity.UserInfo;
import com.wubo.sec.SecurityManager;
import com.wubo.sec.acl.core.AclManager;
import com.wubo.sec.acl.core.EntityAcl;
import com.wubo.sec.core.UserData;

/**
 * @author WuBo
 * @CreateDate 2012-4-24 下午04:25:37
 */
public class UserInfoAcl extends EntityAcl {
	private UserInfo userInfo;
	
	public UserInfoAcl(UserInfo userInfo) {
		super();
		this.userInfo = userInfo;
	}

	@Override
	public int getAcl() {
		UserData user = SecurityManager.getCurrentUser();
		if(user == null){
			return AclManager.getInstance().getAcl("ACL_GET");
		}
		if(user.equals(userInfo.getUser())){
			return super.getAcl();
		}
		if(SecurityManager.isAdmin()){
			return super.getAcl();
		}
		return AclManager.getInstance().getAcl(new String[]{"ACL_GET", "ACL_ADD"});
	}
}
